﻿<UserControl x:Class="Axiom.CodeManifold.WPF.Views.CodeManifoldView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:componentmodel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
			 xmlns:mvvm="clr-namespace:Axiom.CodeManifold.WPF.ViewModels"
			 xmlns:sampledata="clr-namespace:Axiom.CodeManifold.WPF.SampleData"
			 xmlns:converters="clr-namespace:Axiom.CodeManifold.WPF.Converters"
             d:DataContext="{Binding Source={StaticResource SampleData}}"
             mc:Ignorable="d" 
             Loaded="OnLoaded"
			 FontSize="10"
			 FontFamily="Calibri"
             d:DesignHeight="450" d:DesignWidth="460">

	<UserControl.Resources>
		<ObjectDataProvider x:Key="Model" ObjectType="{x:Type mvvm:ModelViewLocator}" MethodName="GetCodeManifoldViewModel"/>
		<sampledata:CodeManifoldSampleData x:Key="SampleData"/>
		<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
		<converters:BoolToRedOrGreenImage x:Key="BoolToRedOrGreenImage"/>
		<converters:ObjectRefToRedOrGreenImage x:Key="ObjectRefToRedOrGreenImage"/>
		<converters:SplitPascalCamelCaseConverter x:Key="SplitPascalCase"/>
		<Style TargetType="ListViewItem">
			<Style.Resources>
				<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{x:Static SystemColors.HighlightColor}"/>
			</Style.Resources>
		</Style>
	</UserControl.Resources>
	<UserControl.DataContext>
		<Binding Source="{StaticResource Model}"/>
	</UserControl.DataContext>
	<Grid>
		<Grid.Background>
			<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
				<GradientStop Color="WhiteSmoke"/>
				<GradientStop Color="#FFDBDBDB" Offset="1"/>
			</LinearGradientBrush>
		</Grid.Background>
		<Grid.RowDefinitions>
			<RowDefinition Height="auto"/>
			<RowDefinition Height="*"/>
			<RowDefinition Height="auto"/>
		</Grid.RowDefinitions>
		<ToolBarTray>
			<ToolBar Band="1" BandIndex="1" ToolBarTray.IsLocked="True" Loaded="OnToolBarLoaded">
				<Button Click="OnLaunchSolutions" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Launch Solutions" Height="20" Visibility="{Binding IsDisconnected, Converter={StaticResource BooleanToVisibilityConverter}}">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/visual.studio.png" />
				</Button>
				<Button Click="OnNew" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="New" Height="25">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/new.png" />
				</Button>
				<Button Click="OnUndo" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Undo" Height="25" Visibility="{Binding Settings.UseUndoContext, Converter={StaticResource BooleanToVisibilityConverter}}">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/undo.png" />
				</Button>
				<Button Click="OnAutoCommentAllFiles" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Auto Comment All Files" Height="25">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/code.png" />
				</Button>
				<Button Click="OnRefresh" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Refresh" Height="25">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/project.working.gif" />
				</Button>
			</ToolBar>
			<ToolBar Band="1" BandIndex="1" ToolBarTray.IsLocked="True" Loaded="OnToolBarLoaded">
				<Button Click="OnSortMembers" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Sort Document" Height="25">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/application.png" />
				</Button>
				<Button Click="OnCommentMembers" BorderBrush="{x:Null}" Background="{x:Null}" ToolTip="Auto Comment Document" Height="25">
					<Image Source="/Axiom.CodeManifold.WPF;component/Assets/Images/Icons/comment.png" />
				</Button>
			</ToolBar>
		</ToolBarTray>
		<TabControl Grid.Row="1" TabStripPlacement="Bottom" Background="{x:Null}">
			<TabItem Header="projects">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="2*"/>
						<RowDefinition Height="*"/>
					</Grid.RowDefinitions>
					<ListBox ItemsSource="{Binding ElementName=ProjectsList, Path=SelectedItem.Properties}">
						<ListBox.ItemTemplate>
							<DataTemplate>
								<Grid>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="160"/>
										<ColumnDefinition Width="0"/>
										<ColumnDefinition Width="*"/>
									</Grid.ColumnDefinitions>
									<TextBlock Grid.Column="0" Text="{Binding Key}"/>
									<TextBlock Grid.Column="2" Text="{Binding Value}"/>
								</Grid>
							</DataTemplate>
						</ListBox.ItemTemplate>
					</ListBox>
					<ListBox Grid.Row="1" x:Name="ProjectsList" ItemsSource="{Binding Projects}" SelectedItem="{Binding SelectedProject}" HorizontalContentAlignment="Stretch">
						<ListBox.ItemTemplate>
							<DataTemplate>
								<Grid Height="25" VerticalAlignment="Center" Background="#ddd" Margin="0,1,1,1" >
									<TextBlock Text="{Binding Name, Converter={StaticResource SplitPascalCase}}" Margin="5,2,2,2" Foreground="Black" VerticalAlignment="Center" FontSize="11"/>
								</Grid>
							</DataTemplate>
						</ListBox.ItemTemplate>
					</ListBox>
				</Grid>
			</TabItem>
			<TabItem Header="settings">
				<StackPanel>
					<Grid DataContext="{Binding Settings}" Margin="2">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="140"/>
							<ColumnDefinition Width="0"/>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Column="0" Text="Root Path"/>
						<TextBox Grid.Column="2" Text= "{Binding RootFolder, UpdateSourceTrigger=PropertyChanged}"/>
					</Grid>
					<Grid DataContext="{Binding Settings}" Margin="2">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="140"/>
							<ColumnDefinition Width="0"/>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Column="0" Text="Site Solution"/>
						<TextBox Grid.Column="2" Text="{Binding RelativeSolutionPath, UpdateSourceTrigger=PropertyChanged}"/>
					</Grid>
					<Grid DataContext="{Binding Settings}" Margin="2">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="140"/>
							<ColumnDefinition Width="0"/>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Column="0" Text="Use Undo Context"/>
						<CheckBox Grid.Column="2" IsChecked="{Binding UseUndoContext, UpdateSourceTrigger=PropertyChanged}"/>
					</Grid>
					<Grid DataContext="{Binding Settings}" Margin="2">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="140"/>
							<ColumnDefinition Width="0"/>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Column="0" Text="Use Regions"/>
						<CheckBox Grid.Column="2" IsChecked="{Binding UseRegions, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}"/>
					</Grid>					
					<Grid DataContext="{Binding Settings}" Margin="2">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="140"/>
							<ColumnDefinition Width="0"/>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Column="0" Text="Add Region Member Count"/>
						<TextBox Grid.Column="2" Width="40" HorizontalAlignment="Left" Text="{Binding RegionMinSize, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}"/>
					</Grid>
					<Grid DataContext="{Binding Settings}" Margin="2">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="140"/>
							<ColumnDefinition Width="0"/>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Column="0" Text="Company Name"/>
						<TextBox Grid.Column="2" Text="{Binding CompanyName, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}"/>
					</Grid>
					<Grid DataContext="{Binding Settings}" Margin="2">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="140"/>
							<ColumnDefinition Width="0"/>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Column="0" Text="Software License Url"/>
						<TextBox Grid.Column="2" Text="{Binding SoftwareLicenseUrl, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}"/>
					</Grid>
				</StackPanel>
			</TabItem>
		</TabControl>
		<StatusBar Grid.Row="2" Height="18" Margin="0,0,0,0">
			<StatusBar.Resources>
				<Style TargetType="TextBlock">
					<Setter Property="FontSize" Value="10"/>
				</Style>
			</StatusBar.Resources>
			<StatusBarItem Padding="0" HorizontalAlignment="Left" Margin="2,0,5,0">
				<ProgressBar IsIndeterminate="True" Width="100" Height="10" Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}" Foreground="Purple"/>
			</StatusBarItem>
			<StatusBarItem Padding="0" HorizontalAlignment="Left" Margin="2,0,0,0">
				<TextBlock Text="{Binding Status}"/>
			</StatusBarItem>
			<StatusBarItem Padding="0" HorizontalAlignment="Right" Margin="0,0,10,0">
				<StackPanel Orientation="Horizontal">
					<TextBlock Text="{Binding Euclid.Ide.Solution.Name}" TextAlignment="Right" Margin="0,0,10,0"/>
					<Image Source="{Binding IsConnected, Converter={StaticResource BoolToRedOrGreenImage}}" ToolTip="{Binding SolutionFullName}" Margin="2"/>
				</StackPanel>
			</StatusBarItem>
		</StatusBar>
	</Grid>
</UserControl>
